#include "Data.h"
#include <iostream>
#include <cassert>

using namespace std;

int Data::s_nrOfInstances = 0;

Data::Data() {
	m_booleanValue = false;
	m_intValue = 0;
	m_floatValue = 0.0f;
	m_stringValue = "";
	s_nrOfInstances++;
}

Data::~Data() {
	s_nrOfInstances--;
}

Data* Data::getCopy() {
	
	Data* d = new Data();
	d->m_type = this->m_type;
	d->m_booleanValue = this->m_booleanValue;
	d->m_intValue = this->m_intValue;
	d->m_floatValue = this->m_floatValue;
	d->m_stringValue = this->m_stringValue;
	
	return d;
}

Data* Data::createBoolean(bool value) {
	Data* newData = new Data();
	newData->m_type = BOOLEAN;
	newData->m_booleanValue = value;
	return newData;
}

Data* Data::createInt(int value) {
	Data* newData = new Data();
	newData->m_type = INT;
	newData->m_intValue = value;
	return newData;	
}

Data* Data::createFloat(float value) {
	Data* newData = new Data();
	newData->m_type = FLOAT;
	newData->m_floatValue = value;
	return newData;	
}

Data* Data::createString(string value) {
	Data* newData = new Data();
	newData->m_type = STRING;
	newData->m_stringValue = value;
	return newData;	
}

Data* Data::createVariableName(string value) {
	assert(value != "");
	Data* newData = new Data();
	newData->m_type = VARIABLE_NAME;
	newData->m_stringValue = value;
	return newData;
}

bool Data::getBooleanValue() {
	assert(m_type == BOOLEAN);
	return m_booleanValue;
}

int Data::getIntValue() {
	assert(m_type == INT);
	return m_intValue;
}

float Data::getFloatValue() {
	assert(m_type == FLOAT);
	return m_floatValue;
}

string Data::getStringValue() {
	assert(m_type == STRING);
	return m_stringValue;
}

string Data::getVariableName() {
	assert(m_type == VARIABLE_NAME);
	return m_stringValue;
}